<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> ThinkAM 开源的mvc生成工具 by thinkphp</title>
<link rel="stylesheet" type="text/css" href="../Public/css/<?php echo ((C("web_css_style"))?(C("web_css_style")):'blue'); ?>.css" />
<script type="text/javascript" src="../Public/js/common.js"></script>
<script type='text/javascript' src='/thinkam/Public/Js/Base.js'></script>  
<script type='text/javascript' src='/thinkam/Public/Js/prototype.js'></script>  
<script type='text/javascript' src='/thinkam/Public/Js/mootools.js'></script>  
<script type='text/javascript' src='/thinkam/Public/Js/Think/ThinkAjax.js'></script>  
<script type='text/javascript' src='/thinkam/Public/Js/Form/CheckForm.js'></script>  
<script type='text/javascript' src='/thinkam/Public/Js/Util/ImageLoader.js'></script>  
<script language="JavaScript">
<!--
//指定当前组模块URL地址 
var URL = '__URL__';
var APP	 =	 '__APP__';
var PUBLIC = '__PUBLIC__';
ThinkAjax.image = [	 '../Public/images/loading2.gif', '../Public/images/ok.gif','../Public/images/update.gif' ]
ImageLoader.add("../Public/images/bgline.gif","../Public/images/bgcolor.gif","../Public/images/titlebg.gif");
ImageLoader.startLoad();
//-->
</script>
</head>

<body onload="loadBar(0)">
<div id="loader" >页面加载中...</div>
<div id="header" class="header">
<div class="headTitle" style="margin:8pt 10pt"> ThinkAM 开源的mvc生成工具 </div>
</div>
<div id="main" class="main" >
<script language="JavaScript">
<!--
 	function runSql(sql){
		window.location.href = '__URL__/index/sql/'+sql;
	}
	function searchTable(table){
		window.location.href = '__URL__/selectTable/table/'+table;
	}

	function refleshDb(db){
		window.location.href = '__ACTION__/dbName/'+db;
	}
	function executeSql(sql){
		var tableName = getSelectCheckboxValues();
		if (tableName == '')
		{
		alert('没有选择数据表');return ;
		}
		sql	 =	 sql.replace('$table',tableName);
		ThinkAjax.send('__URL__/execute','ajax=1&sql='+sql,handleSql);
	}
	function buildTable(tableId,data) { 
		
		for (i=0;i<data.length;i++){ 
		  var row =$(tableId).insertRow(-1);
		  if (i==0)
		  {row.className = 'over';}
		  for (j=0;j<data[i].length;j++) { 
			var cell = document.createElement("td");
			cell.innerHTML = data[i][j];
			row.appendChild(cell); 
		   }
		 }
	 }
	function deleteTable(tableId){
		var Table	=	$(tableId);
			while (Table.rows.length > 0) {
				Table.deleteRow(0);
			}
	}
	function handleSql(data){
		$('resultNum').innerHTML=	 '';
		$('querybox').style.display = 'block';
		deleteTable('table1');
		var time = data.splice(0,1);
		$('resultNum').innerHTML	=	'[ 执行耗时:'+time+' ] ';
		if(data.length>=1) {
			buildTable('table1',data);
		}
	}
	function showTable(){
		executeSql('SHOW COLUMNS FROM $table');
	}
	function checkTable(){
		executeSql('CHECK TABLE $table');
	}
function optimzeTable(){
		executeSql('OPTIMIZE TABLE $table');
	}
	function analyzeTable(){
		executeSql('ANALYZE TABLE $table');
	}
	function repairTable(){
		executeSql('REPAIR TABLE $table');
	}
	function statusTable(){
		executeSql('SHOW TABLE STATUS LIKE  \'$table\'');
	}
	function delTable(){
		var tableName = getSelectCheckboxValues();
		if (window.confirm('确实删除表'+tableName+'吗？'))
		{
		executeSql('DROP TABLE  $table');
		}
	}
	function createTable(){
		window.location.href = '__URL__/add';
		}
	function clearTable(){
		var tableName = getSelectCheckboxValues();
		if (window.confirm('确实清空表'+tableName+'吗？'))
		{
		executeSql('TRUNCATE TABLE $table');
		}
	}
	function outputTable(){
		var tableName = getSelectCheckboxValues();
		window.location.href = '__URL__/output/table/'+tableName;
	}
	function editTable(table){
		window.location.href = '__URL__/editTable/table/'+table;
	}

	function copyTable(table){
		window.location.href = '__URL__/copyTable/table/'+table;
	}
	function moveTable(table){
		window.location.href = '__URL__/moveTable/table/'+table;
	}
	
	//生成
	function makeAction(table){
		window.location.href = '__URL__/makeAction/table/'+table;	
	}
	function makeModel(table){
		window.location.href = '__URL__/makeModel/table/'+table;	
	}
	function makeView(table){
		window.location.href = '__URL__/makeView/table/'+table;	
	}
	
//-->
</script>
<div class="content">
<div class="title">查看数据库<span style="font-weight:normal">[ <?php echo ($useDb); ?> ]  [ <A HREF="__URL__">返回首页</A> ]</span></div>
<div id="result" class="result none"></div>
<!--  功能操作区域  -->
<div class="operate" >
<div class="fLeft">切换数据库：<select name="database" class=" hMargin" onchange="refleshDb(this.options[this.options.selectedIndex].value)">
<?php if(is_array($dbs)): $i = 0; $__LIST__ = $dbs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$db): ++$i;$mod = ($i % 2 )?><?php if(($db["Database"])  !=  "information_schema"): ?><option value="<?php echo ($db["Database"]); ?>" <?php if(($db["Database"])  ==  $useDb): ?>selected<?php endif; ?>> <?php echo ($db["Database"]); ?> </option><?php endif; ?><?php endforeach; endif; else: echo "" ;endif; ?>
   </select>
   </div>
   <div class=" fLeft shadow" ><input type="button" id=""  name="" value="创建" onclick="createTable()" class="button"></div>
<div class=" fLeft shadow" ><input type="button" id=""  name="" value="结构" onclick="showTable()" class="button"></div>
<div class="  fLeft shadow" ><input type="button" id=""  name="" value="优化" onclick="optimzeTable()" class="button"></div>
<div class="  fLeft shadow" ><input type="button" id=""  name="" value="检查" onclick="checkTable()" class="button"></div>
<div class="  fLeft shadow" ><input type="button" id=""  name="" value="分析" onclick="analyzeTable()" class="button"></div>
<div class="  fLeft shadow" ><input type="button" id=""  name="" value="修复" onclick="repairTable()" class="button"></div>
<div class="  fLeft shadow" ><input type="button" id=""  name="" value="状态" onclick="statusTable()" class="button"></div>
<div class=" fLeft shadow" ><input type="button" id=""  name="" value="导出" onclick="outputTable()" class="button"></div>
<div class=" fLeft shadow" ><input type="button" id=""  name="" value="清空" onclick="clearTable()" class="button"></div>
<div class=" fLeft shadow" ><input type="button" id=""  name="" value="删除" onclick="delTable()" class="button"></div>
</div>
<div class="cBoth">
<fieldset  id="queryBox" class="cBoth none" >
<legend style="color:gray">执行结果 <span class="blue" id="resultNum"></span> </legend>
<div id="SqlBench" style="overflow:auto;width:100%;height:100%">
<table cellpadding=0 cellspacing=0 id='table1' class="list" >
</table>
</fieldset>
</div>
<!-- Think 系统列表组件开始 -->
<table id="checkList" class="list" cellpadding=0 cellspacing=0 ><tr><td height="5" colspan="10" class="topTd" ></td></tr><tr class="row" ><th width="8"><input type="checkbox" id="check" onclick="CheckAll('checkList')"></th><th><a href="javascript:sortBy('Name','<?php echo ($sort); ?>','adv')" title="按照名称<?php echo ($sortType); ?> ">名称<?php if(($order)  ==  "Name"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Engine','<?php echo ($sort); ?>','adv')" title="按照类型<?php echo ($sortType); ?> ">类型<?php if(($order)  ==  "Engine"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Rows','<?php echo ($sort); ?>','adv')" title="按照记录数<?php echo ($sortType); ?> ">记录数<?php if(($order)  ==  "Rows"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Data_length','<?php echo ($sort); ?>','adv')" title="按照大小<?php echo ($sortType); ?> ">大小<?php if(($order)  ==  "Data_length"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Data_free','<?php echo ($sort); ?>','adv')" title="按照多余<?php echo ($sortType); ?> ">多余<?php if(($order)  ==  "Data_free"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Collation','<?php echo ($sort); ?>','adv')" title="按照整理<?php echo ($sortType); ?> ">整理<?php if(($order)  ==  "Collation"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Create_time','<?php echo ($sort); ?>','adv')" title="按照创建时间<?php echo ($sortType); ?> ">创建时间<?php if(($order)  ==  "Create_time"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('Comment','<?php echo ($sort); ?>','adv')" title="按照注释<?php echo ($sortType); ?> ">注释<?php if(($order)  ==  "Comment"): ?><img src="../Public/images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th >操作</th></tr><?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): ++$i;$mod = ($i % 2 )?><tr class="row" onmouseover="over(event)" onmouseout="out(event)" onclick="change(event)" ><td><input type="checkbox" name="key"	value="<?php echo ($data["Name"]); ?>"></td><td><a href="javascript:searchTable('<?php echo (addslashes($data["Name"])); ?>')"><?php echo ($data["Name"]); ?></a></td><td><?php echo ($data["Engine"]); ?></td><td><?php echo ($data["Rows"]); ?></td><td><?php echo (getTabeSize($data["Data_length"],$data['Index_length'])); ?></td><td><?php echo (byte_format($data["Data_free"])); ?></td><td><?php echo ($data["Collation"]); ?></td><td><?php echo ($data["Create_time"]); ?></td><td><?php echo ($data["Comment"]); ?></td><td><a href="javascript:copyTable('<?php echo ($data["Name"]); ?>')">复制</a>&nbsp;<a href="javascript:moveTable('<?php echo ($data["Name"]); ?>')">移动</a>&nbsp;<a href="javascript:editTable('<?php echo ($data["Name"]); ?>')">编辑</a>&nbsp;<a href="javascript:makeAction('<?php echo ($data["Name"]); ?>')">生A</a>&nbsp;<a href="javascript:makeModel('<?php echo ($data["Name"]); ?>')">生M</a>&nbsp;<a href="javascript:makeView('<?php echo ($data["Name"]); ?>')">生V</a>&nbsp;</td></tr><?php endforeach; endif; else: echo "" ;endif; ?><tr><td height="5" colspan="10" class="bottomTd"></td></tr></table>
<!-- Think 系统列表组件结束 -->
 

<!--  分页显示区域 -->
<div class="tRight page"><?php echo ($page); ?></div>
</div>
</div>
 <style>
 div.footer{ clear:both; padding:8px 0px; width:100%; text-align:center; font:normal normal normal 12px Verdana,Geneva,Arial,Helvetica,sans-serif; background-color:#464646; border-top:2px solid silver; color:silver}
div.footer a{color:white; text-decoration:none; border-bottom:1px dotted}
div.footer a:hover{color:silver; text-decoration:none; border-bottom:1px dotted}
.think_run_time{text-align:center; width:100%;font-size:12px;}
</style>
{__RUNTIME__}
<!-- 版权信息区域 -->
<div id="footer" class="footer" >Powered by ThinkPHP <?php echo (THINK_VERSION); ?> | Template designed by <a target="_blank" href="http://thinkphp.cn">ThinkPHP</a> <span id="run"></span>
</div>
</body>
</html>